﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EnCor.Logging
{
    public class LogLevel : IComparable
    {
        public static readonly LogLevel Fatal = new LogLevel("Fatal", 5);
        public static readonly LogLevel Error = new LogLevel("Error", 4);
        public static readonly LogLevel Warning = new LogLevel("Warning", 3);
        public static readonly LogLevel Information = new LogLevel("Information", 2);
        public static readonly LogLevel Debug = new LogLevel("Debug" , 1);

        private string _Name;
        private int _Value;

        private LogLevel(string name, int value)
        {
            _Name = name;
            _Value = value;
        }
        

        #region IComparable Members

        public int CompareTo(object obj)
        {
            if ( obj == null )
            {
                throw new ArgumentNullException("obj");
            }

            LogLevel b = obj as LogLevel;
            if (b == null)
            {
                throw new ArgumentException(string.Format("obj {0} is not LogLevel, cannot compare it to LogLevel.", obj));
            }

            return _Value.CompareTo(b._Value);

        }

        public override bool Equals(object obj)
        {
            LogLevel b = obj as LogLevel;
            if (b != null)
            {
                return b._Value == this._Value;
            }
            return base.Equals(obj);
        }

        #endregion

        public override string ToString()
        {
            return _Name;
        }
    }
}
